/**
 * Created by JustinChow on 2016/11/17.
 */

"use strict";

const Util       = require("util");

const GameObject = require("./GameObject");
const Vector     = require("../Utils/Vector");

const StaticDamageConfig = require("../Configs/Datas/Damage.json");

function Damage(objectId, owner, position, gameServer, staticId) {
    GameObject.apply(this, Array.prototype.slice.call(arguments));

    this.staticId = staticId || -1;

    this.staticConfig = this.loadConfig();

    this.damageRate   = this.staticConfig.damageRate   || -1;
    this.targetType   = this.staticConfig.targetType   || -1;
    this.damageType   = this.staticConfig.damageType   || -1;
    this.damageOffset = new Vector(this.staticConfig.damageOffset[0], this.staticConfig.damageOffset[1]) || new Vector();
    this.boxSize      = new Vector(this.staticConfig.damageOffset[0], this.staticConfig.damageOffset[1]) || new Vector();
    this.delay        = this.staticConfig.delay        || -1;
    this.holdTime     = this.staticConfig.holdTime     || -1;
    this.buff         = this.staticConfig.buff         || -1;
    this.casterLevel  = this.staticConfig.casterLevel  || -1;

    /////////////////////////////////////////////////////////////////

    this.time = new Date();
    this.initCollision();
}
Util.inherits(Damage, GameObject);

module.exports = Damage;

Damage.prototype.sendUpdate = function () {
    return false;
};

Damage.prototype.onAdd = function () {

};

Damage.prototype.onRemove = function () {

};

Damage.prototype.move = function () {

};

Damage.prototype.loadConfig = function () {
    if (!StaticDamageConfig[this.staticId]) return {};
    var config = StaticDamageConfig[this.staticId];
    config.throuth = -1;
    return config;
};

Damage.prototype.doDamage = function () {

};